#include "stdafx.h"
#include "Vertex.h"

namespace Framework {

D3DVERTEXELEMENT9* Vertex::vertexElement = NULL;

Vertex::Vertex(void) {
}

Vertex::Vertex(FLOAT x, FLOAT y, FLOAT z) {
    this->x = x;
    this->y = y;
    this->z = z;
}

Vertex::Vertex(FLOAT x, FLOAT y, FLOAT z, FLOAT u, FLOAT v) {
    this->x = x;
    this->y = y;
    this->z = z;
    this->u = u;
    this->v = v;
}

Vertex::Vertex(FLOAT x, FLOAT y, FLOAT z, FLOAT nx, FLOAT ny, FLOAT nz, FLOAT u, FLOAT v) {
    this->x = x;
    this->y = y;
    this->z = z;
    this->nx = nx;
    this->ny = ny;
    this->nz = nz;
    this->u = u;
    this->v = v;
}

D3DVERTEXELEMENT9* Vertex::GetVertexElement() {
    if (Vertex::vertexElement == NULL) {
        D3DVERTEXELEMENT9 vertexElement[] = { // stream number, offset, type, method, usage, usage index
            {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
            {0, 3 * 4, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
            {0, 6 * 4, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
            D3DDECL_END()
        };

        Vertex::vertexElement = vertexElement;
    }

    return Vertex::vertexElement;
}

}
